package com.bjsxt.userCenter.users.back.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.bjsxt.userCenter.users.pojo.AAdmins;


@Component("authInterceptor")
public class AuthInterceptor extends HandlerInterceptorAdapter
{
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
	{
		HttpSession session= request.getSession();
		AAdmins admins =(AAdmins) session.getAttribute("admins");
		if(admins!=null){
			
			return true;
		}else{
			String info="非法登录";
			session.setAttribute("info", info);
			response.sendRedirect(request.getContextPath()+"/login.htm");
			return false;
		}
		
	}
}
